<?php

$data = array (
	"10" =>  array('1','Lada Priora', '10000','1'),
	"11" =>  array('2','Toyota Auris', '30000','0'),
	"12" =>  array('3','Mersedes SL', '100000','1'),
	"14" =>  array('4','Opel Astra', '20000','1'),
	"15" =>  array('5','Toyota Camry', '58000','0'),
	"16" =>  array('6','Taureg', '150000','1'),
	"17" =>  array('7','Lada Priora', '10000','0'),
	"18" =>  array('8','Toyota Auris', '30000','1'),
	"19" =>  array('9','Mersedes SL', '100000','0'),
	"110" =>  array('10','Opel Astra', '20000','1'),
	"111" =>  array('11','Toyota Camry', '58000','1'),
	"112" =>  array('12','Taureg', '150000','1'),
	"113" =>  array('13','Taureg', '150000','0'),
	"114" =>  array('14','Lada Priora', '10000','1'),
	"115" =>  array('15','Toyota Auris', '30000','0'),
	"116" =>  array('16','Mersedes SL', '100000','1'),
	"117" =>  array('17','Opel Astra', '20000','0'),
	"118" =>  array('18','Toyota Camry', '58000','1'),
	"119" =>  array('19','Taureg', '150000','0'),
	"120" =>  array('20','Lada Priora', '10000','1'),
	"121" =>  array('21','Toyota Auris', '30000','0'),
	"122" =>  array('22','Mersedes SL', '100000','1'),
);

// processing additional parameters
if ($_REQUEST['price_prefix']) {
	foreach ($data as &$value) {
		$value[2] = $value[2] . " " . (string)$_REQUEST['price_prefix']; 
	}
}

if (!$_REQUEST['row_id']) {

	$page = $_REQUEST['page'];
	$rows = $_REQUEST['rows'];
	
	$offset = $page * $rows - $rows;
	
	$sort = $_REQUEST['sort'];
	$sortIndex = $_REQUEST['sortIndex'];
	
	if ($sort == 'asc' && $sortIndex == 1) {
		arsort($data);
	}
	
	$response['items'] = array_slice($data, $offset, $rows, true);
	$response['total'] = count($data);
	
	
} else {
	
	$response = $data[$_REQUEST['row_id']];
	// you can use HTML if you want
	$response[1] = "<font color='red'>" . $response[1] . "</font>";
	
}

echo json_encode($response);



